<?php
/*
 *  supplier 供货商添加类
 *
 *  @param $c 一般是类名
 *  @param $a 一般是方法名
 */
class webUrl extends Admin {


    private $webUrlType =array('童装行业','信息收集','产品推广','网站建设','合作伙伴');

    private $childrenSubType = array('亲子','电商','其它');
    private $infoSubType = array('综艺视频','电影电视','新闻资讯','生活美食','旅游资讯','其它');
    private $productSubType = array('推广平台','推广网站','其它');
    private $webSiteSubType = array('行业门户','招聘网站','展销会网站','行业论坛','其它');
    private $companySubType = array('合作网店','合作网站','其它');



    public function index( $c, $a ) {
        include $this->display($c);
    }

    public function  lookWebInfo($c,$a)
    {
        $type = G( 'key1' );
        $this->table = 'webInfo';
        $result = $this->find(array('webUrlType'=>$type));

        include $this->display( $c );
    }


    public function addWebInfo($c,$a)
    {
        $webUrlType = G('webUrlType',0) ;
        $result['webUrlType'] = $webUrlType;
        include $this->display( $c);
    }



    public function edit( $c, $a ) {
        if ( !$id = intval( G( 'id' ) ) ) {
            $this->error();
            exit;
        }

        $this->table = 'webInfo'; // 数据库表名
        $result = $this->find( array( 'id' => $id ) ); // 查找数据
        include $this->display( $c ); // 加载模板
    }





    public function save() {
        # 获取表单数据
        foreach ( $_POST as $key => $val ) {
            $rows[ $key ] = htmlspecialchars( trim( $val ) );
        }

        # 注意 表单字段必须跟数据库表字段名一样
        $this->table = 'webInfo'; // 数据库表名
        if ( $id = intval( G( "id" ) ) ) {
            $msg = $this->update( array( 'id' => $id ), $rows ) ? 'success' : 'failed';  //更新供货商
        } else {
            $msg = $this->create( $rows ) ? 'success' : 'failed';                         // 添加供货商
        }
        exit( $msg );
    }
}